<?php
/**
 * Entry point for Zend Framework.
 *
 * PHP version 5
 *
 * @category   Web
 * @package    Data2People
 * @subpackage Files
 * @author     Mike Bevz <mike.bevz@data2people.com>
 * @copyright  2007-2008 (c) Tourstart.dk
 * @license    The BSD License http://data2people.com/license.txt
 * @version    SVN: $Id: bootstrap.php 13 2008-12-01 16:16:50Z michael.bevz $
 *
 */

require_once dirname(__FILE__).'/global.php';

/**
 * Inits bootstrap
 *
 * @return void
 */
function init()
{
    initConfig();
    
    require_once 'Zend/Controller/Front.php';
    require_once 'TV/View/Smarty.php';
    require_once 'Zend/Controller/Action/Helper/ViewRenderer.php';
    require_once 'Zend/View/Helper/Doctype.php';
    require_once 'Zend/View/Helper/HeadMeta.php';
    
    
    initView();
    initMeta();
    initRoutes();
    initFrontend();
}

/**
 * Inits view
 *
 * @return void
 */
function initView()
{
    $ctrl = Zend_Controller_Front::getInstance();

    $view = TV_View_Smarty::getInstance();

    $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);

    $viewRenderer->setViewScriptPathSpec(':controller/:action.:suffix')
                 ->setViewScriptPathNoControllerSpec(':action.:suffix')
                 ->setViewSuffix('tpl');

    Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
}

/**
 * Inits Meta tags
 *
 * @return void
 */

function initMeta()
{

    $doctypeHelper = new Zend_View_Helper_Doctype();
    $doctypeHelper->doctype('XHTML1_STRICT');

    $metaHelper = new Zend_View_Helper_HeadMeta();
    $metaHelper->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')
               ->appendHttpEquiv('Content-Language', 'en-US')
               ->appendName('keywords', 'news trends analyzer');

}


/**
 * Inits routes
 *
 * @return void
 */
function initRoutes()
{

}

/**
 * Init frontend
 *
 * @return void
 */
function initFrontend()
{
    $ctrl = Zend_Controller_Front::getInstance();
    //$ctrl->addModuleDirectory(dirname(__FILE__)."/Mod");
    $ctrl->setControllerDirectory(APP_PATH . DIRECTORY_SEPARATOR .'Controller');
    $ctrl->dispatch();

}
